<template>
	<view>

		<uni-card title="库存管理">
			<uni-button class="option-button" size="mini"  type="primary" @click="gotoUrl('/pages/kucun/product_stock/add?option_type=2')">产品出库</uni-button>
					<uni-button class="option-button" size="mini"  type="primary" @click="gotoUrl('/pages/kucun/product_stock/add?option_type=1')">产品入库</uni-button>
					<uni-button class="option-button" size="mini"  type="primary" @click="gotoUrl('/pages/kucun/product_stock/add?option_type=3')">出售产品</uni-button>
		</uni-card>
		
		<uni-card title="产品管理">
			<uni-button size="mini" class="option-button"  type="primary" @click="gotoUrl('/pages/kucun/product/add')">新增产品</uni-button>
			<uni-button size="mini" class="option-button"  type="primary" @click="gotoUrl('/pages/kucun/category/add')">新增分类</uni-button>
			<uni-button size="mini" class="option-button"  type="primary" @click="gotoUrl('/pages/kucun/category/list')">分类列表</uni-button>
		</uni-card>

		<uni-card :title="shop.shop_name" v-for="(shop, index) in homeData.shop_data" :extra="'库存总量：' + shop.stock_count">
			<view class="">
				
			</view>
			<view class="">
				今日入库：{{shop.today_in_stock_count}}
			</view>
			<view class="">
				今日出库：{{shop.today_out_stock_count}}
			</view>
			<view class="">
				今日销售：{{shop.today_seal_stock_count}}
			</view>
		</uni-card>
	</view>
</template>
<script>
	import api from "@/utils/api.js"
	export default {
		data() {
			return {
				homeData: {
					"shop_data": []
				}
			}
		},
		methods: {
			gotoUrl(url){
				console.log(url)
				uni.navigateTo({
					url: url
				})
			}
		},
		async onLoad() {
			var query = this.$route.query;
			
			if(query.token){
				uni.setStorageSync("token", query.token)
			}
				
			let { result } = await api.homeData()
			this.homeData = result.data
			console.log(result)
			console.log(query)
			await api.getUser();
			

		}
	}
</script>

<style>

	.item-col{
		text-align: center;
		padding: 30rpx;
	}

	.option-button{
		margin-right: 10rpx;
	}


</style>
